import { PokerAction } from "./Action";
import  { Card } from "./Card";

export class Player {
    public seated: boolean = false;
    public seat: number = null;
    public hand: Card[] = [];       // 玩家手牌
    public chips: number = 0;    // 玩家筹码
    public bet: number = 0;         // 玩家下注金额
    public folded: boolean = false; // 玩家是否弃牌
    public allIn: boolean = false;  // 玩家是否全押
    public action: number = PokerAction.none


    constructor(public uid: string, public username: string) {}

    reset() {
        this.hand = [];
        this.bet = 0;
        this.folded = false;
        this.allIn = false;
    }

    // 接收一张手牌
    recieveCard(card: Card) {
        this.hand.push(card);
    }

    // 是否可以行动
    canAct(): boolean {
        return !this.folded && !this.allIn && this.chips > 0;
    }
}